package io.github.uicdb.liba.api.register;

import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;

import java.util.HashMap;
import java.util.Map;

@Mod.EventBusSubscriber(Dist.CLIENT)
public class LazyClient {
    private static final Map<BlockHolder<?>, RenderType> blockHolderRenderTypeMap = new HashMap<>();

    @SubscribeEvent
    public static void onClientSetup(FMLClientSetupEvent event) {
        event.enqueueWork(() -> {
            blockHolderRenderTypeMap.forEach((blockHolder, renderType) -> ItemBlockRenderTypes.setRenderLayer(blockHolder.get(), renderType));
        });
    }

    public static void setBlockRenderType(BlockHolder<?> blockHolder, RenderType renderType) {
        blockHolderRenderTypeMap.put(blockHolder, renderType);
    }
}
